<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>用户信箱</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="keywords" content="Hosting Store Responsive web template, Bootstrap Web Templates, Flat Web Templates, Andriod Compatible web template,
Smartphone Compatible web template, free webdesigns for Nokia, Samsung, LG, SonyErricsson, Motorola web design" />
    <script type="application/x-javascript"> addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); } </script>
    <link href="${pageContext.request.contextPath}/static/home/css/bootstrap.css" rel='stylesheet' type='text/css' />
    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="${pageContext.request.contextPath}/static/home/js/jquery-1.11.1.min.js"></script>
    <!-- Custom Theme files -->
    <link href="${pageContext.request.contextPath}/static/home/css/style.css" rel='stylesheet' type='text/css' />
    <link href="${pageContext.request.contextPath}/static/home/css/resume_manage.css" rel="stylesheet" type="text/css"/>

    <!-- Custom Theme files -->
    <!-- webfonts -->
    <link href='${pageContext.request.contextPath}/static/home/css/font-awesome.css' rel='stylesheet' type='text/css'/>
    <!-- webfonts -->
    <!-- dropdown -->
    <script src="${pageContext.request.contextPath}/static/home/js/jquery.easydropdown.js"></script>
    <link href="${pageContext.request.contextPath}/static/home/css/nav.css" rel="stylesheet" type="text/css" media="all"/>
    <link href="${pageContext.request.contextPath}/static/admin/css/sweetalert.css" rel="stylesheet">

    <link href="${pageContext.request.contextPath}/static/home/css/resume_manage.css" rel='stylesheet' type='text/css' />
    <link href="${pageContext.request.contextPath}/static/home/css/company_style.css" rel='stylesheet' type='text/css' />
    <!-- start-smoth-scrolling -->
    <script src="${pageContext.request.contextPath}/static/admin/js/sweetalert.min.js"></script>
    <!-- start-smoth-scrolling -->
    <!-- webfonts -->
    <%--<link href='http://fonts.useso.com/css?family=Ubuntu:300,400,500,700' rel='stylesheet' type='text/css'>--%>
    <!-- webfonts -->
    <!-- start-smoth-scrolling -->

    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/home/css/bootstrap-checkbox.css">
    <link href="${pageContext.request.contextPath}/static/home/css/job_management_table.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/home/css/mail_box.css" rel='stylesheet' type='text/css' />
    <!-- start-smoth-scrolling -->
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/home/js/move-top.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/home/js/easing.js"></script>
    <script type="text/javascript">
        jQuery(document).ready(function($) {
            $(".scroll").click(function(event){
                event.preventDefault();
                $('html,body').animate({scrollTop:$(this.hash).offset().top},1000);
            });
        });
    </script>
    <style>
        .support{
            margin: 10px 0;
        }
        .bg-transparent-white-2 {
            margin-top: 10px;
            background-color: rgba(255, 255, 255, 0.2) !important;
            color: #000;
            margin-bottom: 10px;
        }
        .list_3 h2 {
            font-size: 18px;
            color: #4A4545;
            font-weight: 700;
            text-transform: capitalize;
            margin: 0;
        }
        .tab-content .dt-sc-button.small {
            padding: 11px 20px;
            line-height: 16px;
            float: left;
            background: #1BBC9B;
            color: #fff;
            margin-top: 20%;
        }
        .list_3 li{
            padding: 25px 20px;
        }
        ul.list_3 li {
            margin-bottom: 10px;
        }
    </style>
    <%--<link href="css/mail_box.css" rel="stylesheet" type="text/css"/>--%>
    <!-- end-smoth-scrolling -->
</head>
<!-- Header Starts Here -->
<div class="banner inner-banner" >

    <%@include file="../header.jsp"%>

    <div id="breadcrumb_wrapper">
        <div class="container">

            <h3>消息收件箱</h3>
            <h6>&nbsp;</h6>

            <div class="clearfix"></div>
        </div>
    </div>
</div>
<div class="clearfix"> </div>
<!-- Header Ends Here -->
<!--Main Starts Here-->
<div class="container">
    <div class="main-table" style="margin-top: 5%">
        <ul class="nav nav-tabs nav-table" role="tablist">
            <li role="presentation" class="active">
                <a href="#home" aria-controls="home" data-toggle="tab">
                    未读
                </a>
            </li>
            <li role="presentation"><a href="#end" aria-controls="end" data-toggle="tab">已读</a></li>
        </ul>
    </div>
    <div class="tab-content">
        <div class="tile-body color transparent-black rounded-corners tab-pane fade in active " id="home">
            <div class="new_domain">
                <div class="col-md-6">
                    <h4 class="domain-head1">用户投递</h4>
                    <ul class="list_3 delivery">

                    </ul>
                    <div class="tile-footer bg-transparent-white-2 rounded-bottom-corners">
                        <div class="row">

                            <div class="col-sm-offset-4 col-sm-4 text-center">
                                <small class="inline table-options paging-info paging-info1"></small>
                            </div>

                            <div class="col-sm-4 text-right sm-center">
                                <ul class="pagination pagination-xs nomargin pagination-custom pagination1">

                                </ul>
                            </div>

                        </div>
                    </div>
                </div>
                <div class="col-md-6">
                    <h4 class="domain-head1">企业邀请</h4>
                    <ul class="list_3 invite">

                    </ul>
                    <div class="tile-footer bg-transparent-white-2 rounded-bottom-corners">
                        <div class="row">

                            <div class="col-sm-offset-4 col-sm-4 text-center">
                                <small class="inline table-options paging-info paging-info2"></small>
                            </div>

                            <div class="col-sm-4 text-right sm-center">
                                <ul class="pagination pagination-xs nomargin pagination-custom pagination2"></ul>
                            </div>

                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="tile-body color transparent-black rounded-corners tab-pane fade" id="end">
            <div class="new_domain">
                <div class="col-md-6">
                    <h4 class="domain-head1">用户投递</h4>
                    <ul class="list_3 delivery">

                    </ul>
                    <div class="tile-footer bg-transparent-white-2 rounded-bottom-corners">
                        <div class="row">

                            <div class="col-sm-offset-4 col-sm-4 text-center">
                                <small class="inline table-options paging-info paging-info1"></small>
                            </div>

                            <div class="col-sm-4 text-right sm-center">
                                <ul class="pagination pagination-xs nomargin pagination-custom pagination1">

                                </ul>
                            </div>

                        </div>
                    </div>
                </div>
                <div class="col-md-6">
                    <h4 class="domain-head1">企业邀请</h4>
                    <ul class="list_3 invite">

                    </ul>
                    <div class="tile-footer bg-transparent-white-2 rounded-bottom-corners">
                        <div class="row">

                            <div class="col-sm-offset-4 col-sm-4 text-center">
                                <small class="inline table-options paging-info paging-info2"></small>
                            </div>

                            <div class="col-sm-4 text-right sm-center">
                                <ul class="pagination pagination-xs nomargin pagination-custom pagination2"></ul>
                            </div>

                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div id="temp_content" style="display: none;">
    <li>
        <div class="col-lg-9">
            <h2 class="company_name"></h2>
            <p class="add_time"></p>
            <p class="mail_content"></p>
            <div class="classIcon">
                <a class="btn btn-success readDelivery">知道了</a>
                <a class="btn btn-success toDeal">去处理</a>
            </div>
        </div>
        <div class="col-lg-3">
            <p><a class="dt-sc-button small" href="#" target="_blank">简历详情</a></p>
        </div>
    </li>
</div>
<div id="temp_content1" style="display: none;">
    <li>
        <div class="col-lg-9">
            <h2 class="company_name"></h2>
            <p class="add_time"></p>
            <p class="mail_content"></p>
            <div class="classIcon">
                <a class="btn btn-success readDelivery">知道了</a>
                <a class="btn btn-success toDeal">去处理</a>
            </div>
        </div>
        <div class="col-lg-3">
            <p><a class="dt-sc-button small" href="#" target="_blank">简历详情</a></p>
        </div>
    </li>
</div>
<input type="hidden" id="select_num" value="1">
<!--Main Ends Here-->


<!-- #Footer -->
<%@include file="../footer.jsp"%>
<!-- /#Footer -->
<script src="${pageContext.request.contextPath}/static/admin/assets/js/vendor/bootstrap/bootstrap.min.js"></script>
<!-- here stars scrolling icon -->
<script>
    function readDelivery(id){
        $.ajax({
            type:'get',
            url:"${pageContext.request.contextPath}/home/customer/read.action",
            data:'id='+id,
            success:function(json){
                if(json.code == 1){
                    window.location.reload();
                }
            }
        });
    }
    $('#myTabs a').click(function (e) {
        e.preventDefault();
        $(this).tab('show');
        console.log(this);
    });

    $('#myTabs a[href="#profile"]').tab('show') // Select tab by name
    $('#myTabs a:first').tab('show'); // Select first tab
    $('#myTabs a:last').tab('show'); // Select last tab
    $('#myTabs li:eq(2) a').tab('show'); // Select third tab (0-indexed)

    $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
        e.target // newly activated tab
        e.relatedTarget // previous active tab
        var str = e.target.href.toString();
        var s = str.substring(str.lastIndexOf('#'));
        console.log(s);
        if (s == "#home"){
            $('#select_num').val(1);
        }else if(s == "#end") {
            $('#select_num').val(2);
        }
        console.log($('#select_num').val());
        fetchData();
        fetchData2();
    });
</script>
<!-- //here ends scrolling icon -->
<script src="${pageContext.request.contextPath}/static/admin/js/page.js"></script>
<script src="${pageContext.request.contextPath}/static/home/js/page.js"></script>
<script>
    var show = "";
    var fetchData = function (furl) {
        if(furl==null) {
            url = "${pageContext.request.contextPath}/home/company/getMailList.action?p=1";
        }else{
            url = furl;
        }
        var select_num = $('#select_num').val();
        var str = "#home";
        if (select_num == 1){
            str = "#home";
        }else if(select_num == 2) {
            str = "#end";
        }
        $.ajax({
            type:'get',
            url:url,
            data:'select='+select_num,
            success:function(json){
                console.log(json);
                show = json.show;
                if (show=="" ||show.totalRows == 0) {
//                    $(str +" table tbody").html('<tr><td colspan="10" align="center">暂无记录</td></tr>');
                    $('.paging-info1').html("showing 0-0 of 0 items");
                    $('.pagination1').html("");
                    return;
                } else {
                    var list = json.data;
                    var body = $(str +" .delivery");
                    var temp_body = $('#temp_content');
                    var string = "";
                    for (var i in list) {
                        $("#temp_content .classIcon").attr("style","display:block");
                        $("#temp_content .company_name").html(list[i].customer.fullname);
                        $("#temp_content .add_time").html(list[i].date_added_string);
                        if (select_num == 1) {
                            $("#temp_content .classIcon .readDelivery").attr("href", "javascript:readDelivery(" + list[i].delivery_activity_id + ")");
                            $("#temp_content .classIcon .toDeal").attr("href", "${pageContext.request.contextPath}/home/company/dealDelivery.action?job_id="+list[i].delivery.job_id+"&id="+list[i].delivery_activity_id+"&type=0");
                        }else if(select_num ==2){
                            $("#temp_content .classIcon .readDelivery").attr("href", "");
                            $("#temp_content .classIcon .toDeal").attr("href", "");
                            $("#temp_content .classIcon").attr("style","display:none");
                        }
                        $("#temp_content .mail_content").html('投递了\"'+list[i].delivery.job.job_name+'\"岗位，请尽快处理！');
                        $("#temp_content .small").attr("href","${pageContext.request.contextPath}/home/resume/detailForCompany.action?resume_id="+list[i].delivery.resume_id)
                        string += temp_body.html();
                    }
                    body.html(string);
                    if(show.currentPage == show.totalPage){
                        $('.paging-info1').html("showing "+(show.startIndex+1)+"-"+show.totalRows+" of "+show.totalRows+" items");
                    }else {
                        $('.paging-info1').html("showing "+(show.startIndex+1)+"-"+show.endIndex+" of "+show.totalRows+" items");
                    }
                    make_page(show,'.pagination1','?');
                }
            }
        });
    };

    fetchData();

</script>
<script>
    function readInvite(id){
        $.ajax({
            type:'get',
            url:"${pageContext.request.contextPath}/home/company/readInvite.action",
            data:'id='+id,
            success:function(json){
                if(json.code == 1){
                    window.location.reload();
                }
            }
        });
    }

    var show1 = "";
    var fetchData2 = function (furl) {
        if(furl==null) {
            url = "${pageContext.request.contextPath}/home/company/getMailList1.action?p=1";
        }else{
            url = furl;
        }
        var select_num = $('#select_num').val();
        var str = "#home";
        if (select_num == 1){
            str = "#home";
        }else if(select_num == 2) {
            str = "#end";
        }
        $.ajax({
            type:'get',
            url:url,
            data:'select='+select_num,
            success:function(json){
                console.log(json);
                show1 = json.show;
                if (show1=="" ||show1.totalRows == 0) {
//                    $(str +" table tbody").html('<tr><td colspan="10" align="center">暂无记录</td></tr>');
                    $('.paging-info2').html("showing 0-0 of 0 items");
                    $('.pagination2').html("");
                    return;
                } else {
                    var list = json.data;
                    var body = $(str +" .invite");
                    var temp_body = $('#temp_content1');
                    var string = "";
                    for (var i in list) {
                        $("#temp_content1 .classIcon").attr("style","display:block");
                        $("#temp_content1 .classIcon .toDeal").attr("");
                        $("#temp_content1 .company_name").html(list[i].customer.fullname);
                        $("#temp_content1 .add_time").html(list[i].date_added_string);
                        if (select_num == 1) {
                            $("#temp_content1 .classIcon .readDelivery").attr("href", "javascript:readInvite(" + list[i].invite_activity_id + ")");
                            if(list[i].status == 1)
                                $("#temp_content1 .classIcon .toDeal").attr("href", "${pageContext.request.contextPath}/home/company/dealDelivery.action?job_id="+list[i].invite.job_id+"&id="+list[i].invite_activity_id+"&type=1");
                            else{
                                $("#temp_content1 .classIcon .toDeal").attr("style","display:none");
                                $("#temp_content1 .classIcon .toDeal").attr("href","");
                            }
                        }else if(select_num ==2){
                            $("#temp_content1 .classIcon .readDelivery").attr("href", "");
                            $("#temp_content1 .classIcon .toDeal").attr("href","");
                            $("#temp_content1 .classIcon").attr("style","display:none");
                        }
                        var status_string = "";
                        if(list[i].status == 0){
                            status_string="还未接受";
                            $("#temp_content1 .mail_content").html(status_string+'您邀请的\"'+list[i].invite.job.job_name+'\"岗位。');
                        }else if(list[i].status == 1){
                            status_string="接受了";
                            $("#temp_content1 .mail_content").html(status_string+'您邀请的\"'+list[i].invite.job.job_name+'\"岗位。赶紧去安排面试吧！');
                        }else if(list[i].status == 2){
                            status_string="拒绝了";
                            $("#temp_content1 .mail_content").html(status_string+'您邀请的\"'+list[i].invite.job.job_name+'\"岗位。赶快寻找下一个人才吧！');
                        }

                        $("#temp_content1 .small").attr("href","${pageContext.request.contextPath}/home/resume/detailForCompany.action?resume_id="+list[i].invite.resume_id)
                        string += temp_body.html();
                    }
                    body.html(string);
                    if(show1.currentPage == show1.totalPage){
                        $('.paging-info2').html("showing "+(show1.startIndex+1)+"-"+show1.totalRows+" of "+show1.totalRows+" items");
                    }else {
                        $('.paging-info2').html("showing "+(show1.startIndex+1)+"-"+show1.endIndex+" of "+show1.totalRows+" items");
                    }
                    make_page2(show1,'.pagination2','?');
                }
            }
        });
    };

    fetchData2();

</script>
<!-- //here ends scrolling icon -->
</body>
</html>